﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentValidation;
using Microhard.WeixinMP.Models;
using Microhard.WeixinMP.Msg;

namespace Microhard.WeixinMP.Validators
{
    public class FeedbackModelValidator : AbstractValidator<FeedbackModel>
    {
        public FeedbackModelValidator()
        {
            RuleSet("Insert", () =>
            {
                RuleFor(u => u.Content).NotEmpty().WithMessage(FeedbackModelMsg.NeedContent).When(r => r.FeedbackID == Guid.Empty);
                RuleFor(u => u.Content).Length(1, 500).WithMessage(FeedbackModelMsg.ContentMaxLength).When(r => r.FeedbackID == Guid.Empty);
                RuleFor(u => u.QQMail).NotEmpty().WithMessage(FeedbackModelMsg.NeedQQMail).When(r => r.FeedbackID == Guid.Empty);
                RuleFor(u => u.QQMail).Length(1, 50).WithMessage(FeedbackModelMsg.MaxQQMailLength).When(r => r.FeedbackID == Guid.Empty);
            });
            RuleSet("Update", () =>
            {
                RuleFor(u => u.Result).NotEmpty().WithMessage(FeedbackModelMsg.NeedResult);
                RuleFor(u => u.Result).Length(1, 500).WithMessage(FeedbackModelMsg.ResultMaxLength);
            });
        }
    }
}
